<template>
  <div>
      <h2>用户登录</h2>
      <input v-model="user.username">
      <input type="password" v-model="user.password">
      <button @click="onLogin">登录</button>
  </div>
</template>

<script>
export default {
    layout:'blank',
    data(){
        return{
            user:{
                username:"",
                password:""
            }
        }
    },
    methods:{
        onLogin(){
            this.$store.dispatch("/user/login",this.user).then(ok => {
                if(ok){
                    console.log(this.$route.query.redirect)
                    const redirect = this.$route.query.redirect || '/';
                    this.$router.push(redirect);
                }
            })
        }
    }
  
}

</script>
<style lang='scss' scoped>
</style>
